//
//  CollectionLayout.swift
//  Hyphenate-Demo-Swift
//
//  Created by cydida on 2018/12/2.
//  Copyright © 2018年 curtainups. All rights reserved.
//

import UIKit

class CollectionLayout: UICollectionViewFlowLayout {
    override init() {
        super.init();
        
        let screenWidth:Int = Int(UIScreen.main.bounds.width)
        
        let width = (screenWidth - 6 * 20 ) / 5
        
        self.itemSize = CGSize(width: 50, height: width + 25);
        self.minimumLineSpacing = 20;
        self.minimumInteritemSpacing = 20;
        
        self.scrollDirection = .vertical
    }
    
    override func prepare() {
        
        super.prepare()
        
        let screenWidth:Int = Int(UIScreen.main.bounds.width)
        
        let width = (screenWidth - 6 * 20 ) / 5
        
        self.itemSize = CGSize(width: width, height: width + 25 + 20);
        self.minimumLineSpacing = 20;
        self.minimumInteritemSpacing = 20;
        
        self.scrollDirection = .vertical
        
        self.headerReferenceSize = CGSize(width: CGFloat(screenWidth), height: 50)
        //设置边距(让第一张图片与最后一张图片出现在最中央)
//        self.sectionInset = UIEdgeInsetsMake(0, inset, 0, inset)
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
//        fatalError("init(coder:) has not been implemented")
    }
}
